<%@ page language="java" import="java.util.*" pageEncoding="UTF-8"%>
<script type="text/javascript">
	$('#admin_cdgl_datagrid').datagrid({
		url : '${pageContext.request.contextPath}/sysfunAction!gridTree.action',
		fit:true,
		border:false,
		pagination:true,
		idField:'id',
		fitColumns:true,
		//rownumbers:true,不建议使用
		sortName:'name',
		sortOrder:'asc',
		checkOnSelect:true,
		selectOnCheck:true,
		pageSize:5,
		pageList:[5,6,10,20,30,],
		columns : [ [ {
			field : 'id',
			title : '编号', 
			width : 150,
			checkbox:true
		}, {
			field : 'text',
			title : '菜单名称',
			width : 150,
			sortable:true
		}, {
			field : 'nodeurl',
			title : '连接地址',
			width : 150,
			sortable:true
		}, {
			field : 'pid',
			title : '父级菜单',
			width : 150,
			sortable:true
		},{
			field : 'modifydatetime',
			title : '操作',
			width : 150,
			sortable:true
		}] ],
		toolbar:[{
			text:'增加',
			iconCls:'icon-add',
			handler:function(){
				addpendCdgl();
			}
		},'-',{
			text:'删除',
			iconCls:'icon-remove',
			handler:function(){
				removeCdgl();
			}
		},'-',{
			text:'修改',
			iconCls:'icon-edit',
			handler:function(){
				eidtFun();
			}
		}]
	});
	function addpendCdgl(){
		$('#admin_cdgl_addForm input').val('');
		$('#admin_cdgl_addDialog').dialog('open');
	} 	
	function removeCdgl(){
		var rows=$('#admin_cdgl_datagrid').datagrid('getChecked');
		var ids= [];
		if(rows.length>0){
		  $.messager.confirm('确认','您是否要确认删除当前选中的菜单？',function(r){
		   	if(r){
					for(var i=0;i<rows.length;i++){
						ids.push(rows[i].id);
					}
					$.ajax({
						url:'${pageContext.request.contextPath}/sysfunAction!removeCdgl.action',
						data:{
							ids:ids.join(',')
						},
						dataType:'json',
						success:function(d){
							$('#admin_cdgl_datagrid').datagrid('load');
							$('#admin_cdgl_datagrid').datagrid('unselectAll');
							$.messager.show({
								title:'提示',
								msg:d.msg
							});
						}
					});
				}
		  });
		}else{
			$.messager.show({
				title:'提示',
				msg:'请选中要删除的行'
			});
		}
	}
</script>
<div id="admin_cdgl_layout" class="easyui-layout" data-options="fit:true,border:false">
	<div data-options="region:'center',border:false">
		<table id="admin_cdgl_datagrid"></table>
	</div>
</div>
  <div id="admin_cdgl_addDialog" class="easyui-dialog" title="添加菜单" style="width:520px;height:170px;"  
            data-options="iconCls:'icon-save',closed:true,modal:true,buttons:[{
				text:'增加',
				iconCls:'icon-add',
				handler:function(){
				    $('#admin_cdgl_addForm').form('submit', {  
				      		url:'${pageContext.request.contextPath}/sysfunAction!addCdgl.action',
				      		success: function(r){  
				      		var obj=jQuery.parseJSON(r);
				      		if(obj.success){
				      			$('#admin_cdgl_datagrid').datagrid('insertRow',{
				      				index:0,
				      				row:obj.obj
				      			});
				      			$('#admin_cdgl_addDialog').dialog('close');
				      		}
				      		$.messager.show({
				      			title:'提示',
				      			msg:obj.msg
				      		});
				        }  
				    });  
				}
			}]">  
       <form id="admin_cdgl_addForm" method="post">
	<table>
		<tr>
			<th>编号</th>
			<th><input name="id" readonly="readonly"/></th>
			<th>菜单名称</th>
			<td><input name="text" class="easyui-validatebox" data-options="required:true"/></td>
		</tr>
		<tr>
			<th>连接地址</th>
			<th><input name="nodeurl" class="easyui-validatebox" data-options="required:true"/>
			<th>父级菜单</th>
			<td>
				<select id="pid" class="easyui-combobox" name="pid" style="width:200px;" data-options="required:true">
					<option>ss</option>
				</select>
			</td>
		</tr>
		<tr>
			<th>排序位置</th>
			<td><input name="DisplayOrder"/></td>
			<th></th>
			<td>
			
			</td>
		</tr>
	</table>
	</form>
    </div>  
    